//
//  MemberTopViewCollectionViewCell.m
//  quxiangtao
//
//  Created by xbmios on 2018/7/27.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "MemberTopViewCollectionViewCell.h"

@interface MemberTopViewCollectionViewCell ()

@property (strong, nonatomic) UIImageView *bgIV;
@property (strong, nonatomic) UIImageView *memberIV;
@property (strong, nonatomic) UILabel *titleL;
@property (strong, nonatomic) UILabel *desL;

@end

@implementation MemberTopViewCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        [self.contentView addSubview:self.bgIV];
        [self.contentView addSubview:self.memberIV];
        [self.contentView addSubview:self.titleL];
        [self.contentView addSubview:self.desL];
        
    }
    return self;
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    __weak typeof(self) weakSelf = self;
    [self.bgIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
//        make.left.mas_equalTo(weakSelf.contentView.mas_left);
//        make.right.mas_equalTo(weakSelf.contentView.mas_right);
//        make.top.mas_equalTo(weakSelf.contentView.mas_top);
//        make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom);
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        make.centerX.mas_equalTo(weakSelf.contentView.mas_centerX);
        make.width.mas_equalTo(jisuan(230));
        make.height.mas_equalTo(jisuan(100));
    }];
    [self.memberIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        make.left.mas_equalTo(weakSelf.contentView.mas_left).with.offset(jisuan(20));
        make.width.mas_equalTo(jisuan(60));
        make.height.mas_equalTo(jisuan(60));
    }];
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(weakSelf.contentView.mas_top).with.offset(jisuan(16));
        make.left.mas_equalTo(weakSelf.memberIV.mas_right).with.offset(jisuan(10));
        make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(10));
        make.height.mas_equalTo(jisuan(34));
    }];
    [self.desL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(weakSelf.memberIV.mas_bottom);
        make.left.mas_equalTo(weakSelf.memberIV.mas_right).with.offset(jisuan(10));
        make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(10));
        make.top.mas_equalTo(weakSelf.titleL.mas_bottom).with.offset(jisuan(6));
    }];
    
}

#pragma mark -lazy
- (UIImageView *)bgIV {
    
    if (!_bgIV) {
        
        _bgIV = [[UIImageView alloc] init];
        _bgIV.contentMode = UIViewContentModeScaleAspectFit;
        _bgIV.image = [UIImage imageNamed:@"memberTopCellBG"];
    
    }
    
    return _bgIV;
}

- (UIImageView *)memberIV {
   
    if (!_memberIV) {
        
        _memberIV = [[UIImageView alloc] init];
        _memberIV.contentMode = UIViewContentModeScaleAspectFit;
        _memberIV.image = [UIImage imageNamed:@"topViewCellMemberBG"];
        
    }
    
    return _memberIV;
}

- (UILabel *)titleL {
    
    if (!_titleL) {
        
        _titleL = [[UILabel alloc] init];
        _titleL.text = @"会员专享券";
        _titleL.textColor = Color333333;
        _titleL.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:jisuan(24)];
    }
    return _titleL;
}
- (UILabel *)desL {
    
    if (!_desL) {
        
        _desL = [[UILabel alloc] init];
        _desL.text = @"不低于320";
        _desL.textColor = Color999999;
        _desL.font = Font(20);
    }
    return _desL;
}

@end
